/*
 * @Author: 'Chenfarry' '2925102113@qq.com'
 * @Date: 2024-03-13 15:54:54
 * @LastEditors: chenhuanhuan 2925102113@qq.com
 * @LastEditTime: 2024-11-22 21:23:04
 * @FilePath: \liuyanggui\src\api\business\menu\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { getApi, postApi } from "../../config/request";
import { AxiosPromise } from "axios";

/**
 * 查询所有资源Tree
 */
export const reqAllMenuTree = (params: object = {}): AxiosPromise => {
  return getApi("/system/auth_resource/query_all", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};

// 查询单个目录、资源
export const reqSingalMenu = (params: { id: string }): AxiosPromise => {
  return getApi("/system/auth_resource/get_one", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};

// 查询单个角色下所有资源
export const reqRoleSource = (params: object = {}): AxiosPromise => {
  return getApi("/system/auth_resource/get_tree", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};

// 查询多个角色下所有资源-登录后获取权限
export const reqMultiRoles = (params: object = {}): AxiosPromise => {
  return postApi("/system/auth_resource/roles_tree", params, {
    "Content-Type": "application/json",
  });
};

// 删除菜单
export const reqDeleteMenu = (params: object = {}): AxiosPromise => {
  return postApi("/system/auth_resource/delete", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 新增目录、菜单
export const reqAddMenu = (params: object = {}): AxiosPromise => {
  return postApi("/system/auth_resource/save", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 修改目录、菜单
export const reqModifyMenu = (params: object = {}): AxiosPromise => {
  return postApi("/system/auth_resource/modify", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 新增/删除按钮
export const reqSaveBtn = (params: object = {}): AxiosPromise => {
  return postApi("/system/auth_resource/save_button", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};
